import { defineStore } from "pinia";
import { type RouteRecordRaw, useRoute, useRouter } from "vue-router";

export const useRouterStore = defineStore("router", () => {
  const router = useRouter();
  const route = useRoute();

  function resetRouter(accessRoutes: RouteRecordRaw[]) {
    accessRoutes.forEach((item: RouteRecordRaw) => {
      router.hasRoute(item.name!) && router.removeRoute(item.name!);
    });
  }

  return {
    router,
    route,
    resetRouter,
  };
});
